import axios from 'axios'

const API_BASE_URL = 'http://localhost:8123/api'

const apiClient = axios.create({
  baseURL: API_BASE_URL,
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  }
})

export const jobAssistantApi = {
  /**
   * 与求职助手聊天（SSE方式）
   * @param {string} message - 用户发送的消息
   * @param {string} chatId - 会话ID
   * @returns {EventSource} - SSE事件源
   */
  chatWithJobAssistant(message, chatId) {
    const url = `${API_BASE_URL}/ai/job_app/chat/sse?message=${encodeURIComponent(message)}&chatId=${encodeURIComponent(chatId)}`
    return new EventSource(url)
  }
}

export const superAgentApi = {
  /**
   * 与超级智能体聊天
   * @param {string} message - 用户发送的消息
   * @returns {EventSource} - SSE事件源
   */
  chatWithSuperAgent(message) {
    const url = `${API_BASE_URL}/ai/manus/chat?message=${encodeURIComponent(message)}`
    return new EventSource(url)
  }
}

export default apiClient 